package com.lbssoft.datalink;

import com.lbssoft.datalink.util.Log;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.util.Date;

import com.lbssoft.datalink.model.BaseMsg;

@Sharable
public class SubServerHandler extends SimpleChannelInboundHandler<BaseMsg> {

	@Override
	public void channelActive(ChannelHandlerContext ctx) throws Exception {
		ctx.fireChannelActive();
	}

	@Override
	public void channelInactive(ChannelHandlerContext ctx) throws Exception {
	}

	@Override
	protected void messageReceived(ChannelHandlerContext ctx, BaseMsg msg)
			throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
		super.exceptionCaught(ctx, cause);
		Channel channel = ctx.channel();
		Log.info("sdk exceptionCaught");
		if(channel.isActive())ctx.close();
	}
}